using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter17
{
	/// <summary>
	/// Example06: Doppler Submarines
	/// A submarine (sub A) travels through water at a speed
	/// of 8.0 m/s, emitting a sonar wave at a frequency of
	/// 1400 Hz. The speed of sound in the water is 1533 m/s.
	/// A second submarine (sub B) is located such that both
	/// submarines are traveling directly toward one another.
	/// The second submarine is moving at 9.0 m/s.
	/// (A) What frequency is detected by an observer riding
	/// on sub B as the subs approach each other?
	/// f' = 1416 Hz
	/// (B) The subs barely miss each other and pass. What frequency
	/// is detected by an observer riding on sub B as the subs
	/// recede from each other?
	/// f' = 1385 Hz
	/// </summary>
	public class Example06
	{
		public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Sound s = new L.Sound();
			s.TypicalSpeed = 1533.0;
			L.Frequency fs = new L.Frequency();
			fs.Hz = 1400.0;
			L.Speed vs = new L.Speed();
			vs.mPERs = 8.0;
			L.Frequency fo = new L.Frequency();
			fo.VariableQ = true;
			L.Speed vo = new L.Speed();
			vo.mPERs = 9.0;
			s.DopplerEffect(fs,vs,fo,vo);
			result+=Convert.ToString(fo.Hz)+"\r\n";      
			vs.mPERs = -8.0;
			vo.mPERs = -9.0;
			s.DopplerEffect(fs,vs,fo,vo);
			result+=Convert.ToString(fo.Hz);  
		}
	}
}
